import { mapState } from 'vuex';

// 全局变量——存储
export default {
  computed: {
    ...mapState({
      isAppReady: state => state.cms.isAppReady,
      isLaunchReady: state => state.cms.isLaunchReady,
    }),
  },
  methods: {
    getLaunchReady() {
      // onLaunch状态加载监控
      return new Promise(resolve => {
        const getLaunchReadyF = () => {
          const status = this.isLaunchReady;
          if (status) {
            resolve();
          } else {
            setTimeout(() => {
              getLaunchReadyF();
            }, 50);
          }
        };

        getLaunchReadyF();
      });
    },
    getBindLoginStatus() {
      // 初始化加载监控
      return new Promise(resolve => {
        const getBindLoginStatusF = () => {
          const status = this.isAppReady;
          if (status) {
            resolve();
          } else {
            setTimeout(() => {
              getBindLoginStatusF();
            }, 50);
          }
        };

        getBindLoginStatusF();
      });
    },
  },
};
